package mylab.io.base.fsm;

import com.google.common.collect.Lists;

import java.util.List;
import java.util.function.Consumer;

import mylab.base.foundation.lang.Callback;

public class DasStoppedState extends AbstractState {

    @Override
    public DasStatus getStatus() {
        return DasStatus.Stopped;
    }

    @Override
    public List<DasAction> getSupportedActions() {
        return Lists.newArrayList(DasAction.Start, DasAction.Dispose, DasAction.Stop);
    }

    @Override
    public void execute(FsmContext context, DasAction action, Callback<Void> callback) {
        super.execute(context, action, callback);

        switch (action) {
            case Start ->
                    context.startFunc(Callback.simple(callback, (Consumer<Void>) unused -> context.setDasState(new DasRunningState())));
            case Dispose ->
                    context.disposeFunc(Callback.simple(callback, (Consumer<Void>) unused -> context.setDasState(new DasShutdownState())));
            case Stop -> {
                // do nothing
            }
        }

    }
}
